﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using OpenTK.Graphics.OpenGL;
using OpenTK;

namespace MyOpenGame
{
    public class AModel
    {
        protected List<Vector2> _points;
        protected int _row;
        protected int _texture;
        protected int _movedX;
        protected int _moveStep;
        protected int _lifePoints;
        protected int _yTopLimit;
        protected int _yBottomLimit;

        public AModel()
        {
            _movedX = 0;
        }

        public AModel(int row)
        {
            _row = row;
            _movedX = 0;
        }

        public int GetLifePoints()
        {
            return _lifePoints;
        }

        public void RemoveLifePoints(int damage)
        {
            _lifePoints -= damage;
        }

        public int GetRow()
        {
            return _row;
        }

        public virtual void Draw()
        {
            _movedX += _moveStep;

            GL.LoadIdentity();
            GL.BindTexture(TextureTarget.Texture2D, _texture);
            GL.Begin(BeginMode.Quads);
            GL.TexCoord2(0, 0); GL.Vertex2(_points[0].X + _movedX, _points[0].Y);
            GL.TexCoord2(1, 0); GL.Vertex2(_points[1].X + _movedX, _points[1].Y);
            GL.TexCoord2(1, 1); GL.Vertex2(_points[2].X + _movedX, _points[2].Y);
            GL.TexCoord2(0, 1); GL.Vertex2(_points[3].X + _movedX, _points[3].Y);
            GL.End();
        }

        public virtual List<Vector2> GetCurrentPosition()
        {
            var currentPotition = new List<Vector2>();
            currentPotition.Add(new Vector2(_points[0].X + _movedX, _points[0].Y));
            currentPotition.Add(new Vector2(_points[1].X + _movedX, _points[1].Y));
            currentPotition.Add(new Vector2(_points[2].X + _movedX, _points[2].Y));
            currentPotition.Add(new Vector2(_points[3].X + _movedX, _points[3].Y));
            return currentPotition;
        }

    }
}
